import { toast } from "../../components/Toast/Toast";
import { keywordApi } from "../backend/server";
// import { getKeywordList } from "../common/common";
import { KeywordListType } from "../domain/keyword";
// import { updateKeywordList } from "../common/common";

export async function install(
  val: string,
  list: KeywordListType,
  clearInputCallBack: () => void
) {
  // const list = getKeywordList();
  const key: string = val.replace("remove ", "");

  // const chosen = list.find((val) => val.keyName === key)?.id;
  // if (!chosen) return toast("cannot find target!");

  try {
    const data = await keywordApi.removeKeywordByKey(key);
  } catch (err) {
    toast("remove failed!");
    throw "remove failed!";
  }
  toast("removed!");

  // refreshKeywordList();
  clearInputCallBack();
}
